*** This code adjusts the TAXSIM variables to account for the student loan interest deduction

*NOTE: mstat :: 1=single/hoh, 2=mfj, 6=mfs, 8=dependent taxpayer

gen double TEMP_agi = pwages + swages + dividends + intrec + max(-3000,stcg+ltcg) ///
					+ otherprop + nonprop + pensions + gssi + ui + transfers + scorp ///
					+ pbusinc + sbusinc + pprofinc + sprofinc ///
					- 0.5*0.9235*0.153*(scorp + pbusinc + sbusinc + pprofinc + sprofinc)

gen double TEMP_agi_no_gssi = TEMP_agi - gssi

gen double TEMP_student_interest_ded = 0
replace    TEMP_student_interest_ded = min(2500,cdw_sl_int) if mstat!=6

gen double TEMP_thresh1 = 140e3
replace    TEMP_thresh1 = TEMP_thresh1/2 if mstat!=2

gen double TEMP_thresh2 = 170e3
replace    TEMP_thresh2 = TEMP_thresh2/2 if mstat!=2

gen TEMP_phzout = max(0,min(1,(TEMP_agi_no_gssi-TEMP_thresh1)/(TEMP_thresh2-TEMP_thresh1)))

replace nonprop = nonprop - TEMP_student_interest_ded*(1-TEMP_phzout)

drop TEMP*
